package org.iks.feign.config;

import io.github.taikonaut3.virtue.boot.EnableVirtue;
import io.github.taikonaut3.virtue.config.MatchRule;
import io.github.taikonaut3.virtue.config.manager.Virtue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author WenBo Zhou
 * @Date 2024/3/12 14:19
 */
@Configuration
@EnableVirtue(
        clientScan = {"org.iks.feign.service.user", "org.iks.feign.service.store"},
        serverScan = "org.iks"
)
public class VirtueRpcConfig {

    @Bean
    public TokenFilter tokenFilter(Virtue virtue) {
        TokenFilter tokenFilter = new TokenFilter();
        // 调用userService的都会经过此过滤器
        tokenFilter.addPathRule(virtue, MatchRule.Scope.client, "userService");
        return tokenFilter;
    }
}
